# runserver in deploy container
cd /app

set -eux

export PYTHONPATH=/app/__pypackages__/3.11/lib
export PATH=${PATH}:/app/__pypackages__/3.11/bin

function start_django() {
    python manage.py createcachetable

    python manage.py makemigrations

    python manage.py migrate

    mkdir -p /var/log/uwsgi

    # replace dev server with uwsgi
    # python manage.py runserver '0.0.0.0:9091'
    uwsgi uwsgi.ini &
}

# proxy /  request to vue ui at /app/dist
# proxy /api request to django 9091
function start_nginx() {
    nginx -c /app/nginx.conf

    tail -f /var/log/uwsgi/uwsgi.log &

    tail -f /var/log/nginx/error.log &

    tail -f /var/log/nginx/access.log &

}

start_django

start_nginx

tail -f /dev/null
